﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

namespace SportingGoodsExhibitionSystem
{
    /// <summary>
    /// HealthyTable.xaml 的交互逻辑
    /// </summary>
    public partial class HealthyTable : Window
    {
        public HealthyTable()
        {
            InitializeComponent();
        }
        int stuNum;
        public HealthyTable(int num)
        {
            InitializeComponent();
            stuNum = num;
        }
        string strCon = Properties.Resources.strCON;
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int one = 0 ;
            if(fnn.IsChecked==true)
            {
                one = 0;
            }
            else if(fny.IsChecked==true)
            {
                one = 1;
            }
            int two = 0;
            if (snn.IsChecked == true)
            {
                two = 0;
            }
            else if (sny.IsChecked == true)
            {
                two = 1;
            }
            int three = 0;
            if (tnn.IsChecked == true)
            {
                three = 0;
            }
            else if (tny.IsChecked == true)
            {
                three = 1;
            }
            int four = 0;
            if (ftn.IsChecked == true)
            {
                four = 0;
            }
            else if (fty.IsChecked == true)
            {
                four = 1;
            }
            int five = 0;
            if (fvn.IsChecked == true)
            {
                five = 0;
            }
            else if (fvy.IsChecked == true)
            {
                five = 1;
            }
            int six = 0;
            if (sxn.IsChecked == true)
            {
                six = 0;
            }
            else if (sxy.IsChecked == true)
            {
                six = 1;
            }
            SqlConnection con = new SqlConnection(strCon);
            con.Open();
            SqlCommand cmd = new SqlCommand("insert into heathyTable(first,second,third,forth,fifth,sixth,stunum) values(@o,@s,@t,@fo,@fi,@si,@stu)", con);
            cmd.Parameters.Add("@o", SqlDbType.Int, 10).Value = one;
            cmd.Parameters.Add("@s", SqlDbType.Int, 10).Value = two;
            cmd.Parameters.Add("@t", SqlDbType.Int, 10).Value = three;
            cmd.Parameters.Add("@fo", SqlDbType.Int, 10).Value = four;
            cmd.Parameters.Add("@fi", SqlDbType.Int, 10).Value = five;
            cmd.Parameters.Add("@si", SqlDbType.Int, 10).Value = six;
            cmd.Parameters.Add("@stu", SqlDbType.Int, 10).Value = stuNum;
            cmd.ExecuteNonQuery();
            con.Close();
            MessageBox.Show("填写完成");
        }
    }
}
